package com.tiandao.mofang.core.util;



import com.tiandao.mofang.core.RobotSingleton;

import java.awt.*;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;

public class YiDong {
    //单例模拟输入对象
    private static Robot robot = RobotSingleton.getInstance();
    public static int QDT_JIU_HUA_Y =65;
    public static int QDT_HANG_ZHOU_Y =90;
    public static int QDT_DONG_YUE_Y =130;
    /**
     * 模拟游戏御风神行的方法
     * @param x  传送点屏幕x坐标
     * @param y  传送点屏幕y坐标
     */
    public static void yfsx(int x ,int y) {
        try {
            Thread.sleep(2000);
            //模拟打开地图M键
            robot.keyPress(KeyEvent.VK_M);
            robot.keyRelease(KeyEvent.VK_M);
            Thread.sleep(1400);
            //将鼠标移动到传送点上
            robot.mouseMove(x,y);
            Thread.sleep(1000);
            //点击鼠标左键
            robot.mousePress(InputEvent.BUTTON1_MASK);
            robot.mouseRelease(InputEvent.BUTTON1_MASK);
            Thread.sleep(1000);
            //可以判断是否是付费御风神行
            //点击付费传送
            robot.mouseMove(955,640);
            Thread.sleep(1000);
            robot.mousePress(InputEvent.BUTTON1_MASK);
            robot.mouseRelease(InputEvent.BUTTON1_MASK);
            Thread.sleep(1600);
            //点击立即传送
            robot.mouseMove(840,640);
            Thread.sleep(1000);
            robot.mousePress(InputEvent.BUTTON1_MASK);
            robot.mouseRelease(InputEvent.BUTTON1_MASK);
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    /**
     * 模拟游戏御风神行(切换地图)的方法
     * @param x  传送点屏幕x坐标
     * @param y  传送点屏幕y坐标
     */
    public static void yfsxqdt(int x ,int y, int dty) {
        try {
            Thread.sleep(2000);
            robot.keyPress(KeyEvent.VK_M);
            robot.keyRelease(KeyEvent.VK_M);
            Thread.sleep(2300);
            robot.mouseMove(130,22);
            Thread.sleep(1500);
            robot.mousePress(InputEvent.BUTTON1_MASK);
            robot.mouseRelease(InputEvent.BUTTON1_MASK);
            Thread.sleep(1500);
            robot.mouseMove(150,dty);
            Thread.sleep(1500);
            robot.mousePress(InputEvent.BUTTON1_MASK);
            robot.mouseRelease(InputEvent.BUTTON1_MASK);
            Thread.sleep(1500);
            robot.mouseMove(x,y);
            Thread.sleep(1500);
            robot.mousePress(InputEvent.BUTTON1_MASK);
            robot.mouseRelease(InputEvent.BUTTON1_MASK);
            Thread.sleep(1500);
            robot.mouseMove(965,640);
            Thread.sleep(1500);
            robot.mousePress(InputEvent.BUTTON1_MASK);
            robot.mouseRelease(InputEvent.BUTTON1_MASK);
            Thread.sleep(1500);
            robot.mouseMove(825,640);
            Thread.sleep(1500);
            robot.mousePress(InputEvent.BUTTON1_MASK);
            robot.mouseRelease(InputEvent.BUTTON1_MASK);
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    /**
     * 去游戏中某个坐标的方法
     * @param x 游戏地图x坐标
     * @param y 游戏地图y坐标
     */
    @SuppressWarnings("all")
    public static void zouLu(String x ,String y) {
        try {
            //打开地图
            Thread.sleep(3000);
            robot.keyPress(KeyEvent.VK_M);
            robot.keyRelease(KeyEvent.VK_M);
            //输入  X坐标
            Thread.sleep(1000);
            robot.mouseMove(710,22);
            Thread.sleep(800);
            robot.mousePress(InputEvent.BUTTON1_MASK);
            robot.mouseRelease(InputEvent.BUTTON1_MASK);
            Thread.sleep(500);
            //将坐标字符串转换为char数组
            char[] xrr = x.toCharArray();
            for (char c: xrr) {
                robot.keyPress(c);
                robot.keyRelease(c);
            }
            //输入  Y坐标
            Thread.sleep(500);
            robot.mouseMove(830,22);
            Thread.sleep(500);
            robot.mousePress(InputEvent.BUTTON1_MASK);
            robot.mouseRelease(InputEvent.BUTTON1_MASK);
            Thread.sleep(500);
            char[] yrr = y.toCharArray();
            for (char c1: yrr) {
                robot.keyPress(c1);
                robot.keyRelease(c1);
            }
            //寻路
            Thread.sleep(500);
            robot.mouseMove(893,22);
            Thread.sleep(500);
            robot.mousePress(InputEvent.BUTTON1_MASK);
            robot.mouseRelease(InputEvent.BUTTON1_MASK);
            //关闭地图
            Thread.sleep(1000);
            robot.keyPress(KeyEvent.VK_M);
            robot.keyRelease(KeyEvent.VK_M);

        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }


}
